from selenium import webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class adminHou(unittest.TestCase):
    def setUp(self):
        #self.driver = webdriver.Firefox()
        self.driver = webdriver.Chrome(executable_path=r"C:\Users\admin\AppData\Local\Google\Chrome\Application\chromedriver")
        self.base_url = "http://admin2.tctest0.com"
        self.verificationErrors = []
        self.accept_next_alert = True

    def test_LiveBroadcast(self):
        #登录
        driver = self.driver

        driver.get(self.base_url)
        driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div/form/div[1]/div/div/input").send_keys('admin')
        driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div/form/div[2]/div/div/input").send_keys('123456')
        driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div/form/div[3]/div/div/input").send_keys('1240')
        driver.find_element_by_xpath("//div[@id='app']/div/div/div/div[2]/div/form/div[4]/div/button").click()
        time.sleep(3)
        #首页
        driver.find_element_by_xpath("//*[@id='LeftMenu']/ul/li[1]/span").click()
        #最近
        driver.find_element_by_xpath("//*[@id='LeftMenu']/ul/li[2]").click()
        #网站--首页设置
        driver.find_element_by_xpath("//*[@id='LeftMenu']/ul/li[3]/span").click()
        driver.find_element_by_xpath("//*[@id='LeftMenu']/ul/li[3]/span").click()
        #网站--公告管理
        driver.find_element_by_xpath("//*[@id='LeftMenu']/ul/li[3]/ul/li[2]/span").click()
        #网站--消息管理
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[3]/ul/li[2]/span").click()
        #网站--消息页配置
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[3]/ul/li[2]/span").click()
        #网站--推广页配置
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[3]/ul/li[4]/span").click()
        #活动
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[4]/span").click()
        #活动--活动列表
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[4]/ul/li[1]/span").click()
        #活动--参与列表
        driver.find_element_by_xpath(".//*[@id='LeftMenu']/ul/li[4]/ul/li[2]").click()
        time.sleep(3)



        #
        # #直播
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/i").click()
        # time.sleep(3)
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li/span").click()
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li[2]/span").click()
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li[3]/span").click()
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li[4]/span").click()
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li[5]/span").click()
        # driver.find_element_by_xpath("//div[@id='LeftMenu']/ul/li[14]/ul/li[6]/span").click()
        # driver.implicitly_wait(5)
    

    #
    # def tearDown(self):
    #     self.driver.quit()
    #     self.assertEqual([], self.verificationErrors)

# if __name__ == "__main__":
#     unittest.main()
